import axios from 'axios';
import Qs from "qs";
import store from "@/store";
const service = axios.create({
	baseURL: "http://121.199.0.35:7001",
	timeout: 10000,
});
service.interceptors.request.use(config => {
	if (store.getters.token){
		config.headers['Authorization'] = store.getters.token
	}
	return config
}, error => {
	return Promise.reject(error)
});
service.interceptors.response.use(response => {
	let res=response.data;
	return res
}, error => {
	return Promise.reject(error)
});
export function get(url, params) {
	return service.get(url, {
		params, timeout: 10000,
		headers: {
			'X-Requested-With': 'XMLHttpRequest'
		}
	})
}
export function postJSON(url,data){
	return service.post(url,data,{
		timeout: 10000,
		headers: {
			'X-Requested-With': 'XMLHttpRequest'
		}
	})
}
export function post(url, data) {
	return service.post(url, Qs.stringify(data), {
		timeout: 10000,
		headers: {
			'X-Requested-With': 'XMLHttpRequest'
		}
	})
}